package com.nj.dms.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.nj.dms.dao.impl.EssayDaoImpl;

/**
 * 删除文章
 */
@WebServlet("/DeleteEssay")
public class DeleteEssay extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		int id = new Integer(request.getParameter("id"));

		EssayDaoImpl essayDaoImpl = new EssayDaoImpl();

		if (essayDaoImpl.deleteEssay(id)) {
			// 文章删除成功，跳转到我的文章页面

			response.sendRedirect("MyEssayList");

		} else {

			// 文章删除失败，跳转到我的文章页面
			response.sendRedirect("MyEssayList");

		}

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
